Add comprehensive test suite covering all commands and edge cases#6
Add comprehensive test suite covering all commands and edge cases#6vedssharma merged 1 commit intomainfrom
Conversation
- internal/http: URL validation (SSRF, cloud metadata blocking, private IPs),
all HTTP methods (GET/POST/PUT/PATCH/DELETE) via httptest, header handling
- internal/format: sanitizeOutput (ANSI escapes, control chars, DEL),
prettyJSON (valid/invalid), status color selection, all print function smoke tests
- internal/storage: full CRUD coverage for history (add, load, limit enforcement,
clear, get by ID), collections (create, add, order, delete, cascade), aliases
(create/upsert, get, delete), and parseJSONHeaders edge cases
- cmd/request: parseHeaders (malformed, multi-value, whitespace trimming),
filterSensitiveHeaders (all sensitive header types, case-insensitive),
warnIfSensitiveBody, resolveAlias (full URLs, alias resolution, trailing slash),
readBodyFromFile (valid, path traversal blocked, symlinks, subdirectories)
- cmd/export: isJSON, parsePostmanURL (path/query/protocol parsing),
buildPostmanRequest (body detection, method casing), integration tests for
buildPostmanFrom{Collection,History,AllCollections}
- cmd/import: resolvePostmanURL (string, object, reconstruct from parts),
flattenPostmanItems (nested folders, deep nesting, prefixes),
convertPostmanRequest (headers, raw body, non-raw mode skip)
176 tests total, all passing.
https://claude.ai/code/session_012s4PVKiEUVA1Sf8zH921ij
PR Review: Comprehensive Test SuiteGreat addition overall — 176 tests across 6 files with solid coverage of security-sensitive paths (SSRF, path traversal, header redaction). A few things worth addressing: Issues1.
// Better: use t.Chdir (Go 1.24+) instead of rolling your own
func TestReadBodyFromFile_ValidFile(t *testing.T) {
dir := t.TempDir()
t.Chdir(dir)
// ...
}2. Go uses // Current
import_time := model.Request{...}
store.AddToHistory(import_time)
// Fix
req := model.Request{...}
store.AddToHistory(req)3. These tests pass even if the warning logic is accidentally removed: func TestWarnIfSensitiveBody_ContainsPassword(t *testing.T) {
warnIfSensitiveBody(`{"username":"alice","password":"s3cr3t"}`)
// ← no assertion that a warning was actually emitted
}If 4. New transitive dependencies in The Minor Notes
What's Working Well
Overall a solid test suite — address the |
all HTTP methods (GET/POST/PUT/PATCH/DELETE) via httptest, header handling
prettyJSON (valid/invalid), status color selection, all print function smoke tests
clear, get by ID), collections (create, add, order, delete, cascade), aliases
(create/upsert, get, delete), and parseJSONHeaders edge cases
filterSensitiveHeaders (all sensitive header types, case-insensitive),
warnIfSensitiveBody, resolveAlias (full URLs, alias resolution, trailing slash),
readBodyFromFile (valid, path traversal blocked, symlinks, subdirectories)
buildPostmanRequest (body detection, method casing), integration tests for
buildPostmanFrom{Collection,History,AllCollections}
flattenPostmanItems (nested folders, deep nesting, prefixes),
convertPostmanRequest (headers, raw body, non-raw mode skip)
176 tests total, all passing.
https://claude.ai/code/session_012s4PVKiEUVA1Sf8zH921ij